﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="LeadershipForm.aspx.cs"
    Inherits="Assesment.Web.Forms.Administration.Catalog.LeadershipForm" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>City Form</title>
    <script src="<%= ResolveUrl("~/scripts/jquery.validate.min.js") %>" type="text/javascript"></script>
    <script src="<%= ResolveUrl("~/scripts/jquery.validate.wrapper.js") %>" type="text/javascript"></script>
    <script src="<%= ResolveUrl("~/scripts/jquery.inputmask.bundle.min.js") %>" type="text/javascript"></script>
    <script src="<%= ResolveUrl("~/scripts/jquery.msgBox.v1.js") %>" type="text/javascript"></script>
    <script src="<%= ResolveUrl("~/scripts/chosen/chosen.jquery.min.js") %>" type="text/javascript"></script>
    <link href="<%= ResolveUrl("~/styles/chosen/chosen.min.css") %>" rel="stylesheet"
        type="text/css" />
    <script type="text/javascript">

        $("#btnSave").button({ icons: { primary: "ui-icon-disk"} });
        $("#btnClose").button({ icons: { primary: "ui-icon-close"} });

        $('#btnClose').click(function () {
            parent.$('#dialog').dialog("close");
        });
 
    </script>
    <script type="text/javascript">

        $(document).ready(function () {

            $('#txtCode').focus();


            // 1. prepare the validation rules and messages.
            var rules = {
                txtCode: "required",
                txtDisc: "required"

            };
            var messages = {
                txtCode: "Code wajib di isi",
                txtDisc: "Disc wajib di isi"
            };

            //            $("#txtDescription").inputmask("Regex", { regex: "[A-Za-z-.0-9 ]*" });

            // 2. Initiate the validator
            var validator = new jQueryValidatorWrapper("form1", rules, messages);

            // 3. Set the click event to do the validation
            $("#btnSave").click(function () {

                if (!validator.validate())
                    return;


                var code = $('#txtCode').val();
                var disc = $('#txtDisc').val();
                var plus = $('#txtPlus').val();
                var minus = $('#txtMinus').val();
                var id = $('#<%= hfID.ClientID %>').val();

                var objrecLeadership = new Object();
                objrecLeadership.LeadershipID = id;
                objrecLeadership.Code = encodeURIComponent(code);
                objrecLeadership.Msdt = encodeURIComponent(disc);
                objrecLeadership.InterpretationPlus = encodeURIComponent(plus);
                objrecLeadership.InterpretationMin = encodeURIComponent(minus);

                jsonData = JSON.stringify(objrecLeadership);

                var handlerUrl = '<%= ResolveUrl("~/ajaxhandler/administration/catalog/Leadershiphandler.ashx") %>';

                if (id == 0)
                    CallAjax(handlerUrl, "?method=insert", jsonData);
                else {
                    CallAjax(handlerUrl, "?method=update", jsonData);
                }

                parent.$('#dialog').dialog('close');

                setTimeout("parent.$('#table').trigger('reloadGrid');", 3000);

                return false;
            });


        });
    
    </script>
    <script type="text/javascript">

        function ClearText() {

        }
         
    </script>
</head>
<body onload="ClearText();">
    <form id="form1" runat="server">
    <table border="0">
        <tr>
            <td valign="top">
                Code
            </td>
            <td valign="top">
                :
            </td>
            <td>
                <asp:TextBox ID="txtCode" runat="server" Width="100"></asp:TextBox>&nbsp;<span style="color: Red;">*</span>
            </td>
        </tr>
        <tr>
            <td valign="top">
                MSDT
            </td>
            <td valign="top">
                :
            </td>
            <td>
                <asp:TextBox ID="txtDisc" runat="server" Width="100"></asp:TextBox>&nbsp;<span style="color: Red;">*</span>
            </td>
        </tr>
      
        <tr>
            <td valign="top">
               Interprestasi Plus
            </td>
            <td valign="top">
                :
            </td>
            <td>
                <asp:TextBox ID="txtPlus" runat="server" TextMode="MultiLine" Rows="7" Width="500"></asp:TextBox>
            </td>
        </tr>
         <tr>
            <td valign="top">
                Interprestasi Minus
            </td>
            <td valign="top">
                :
            </td>
            <td>
                <asp:TextBox ID="txtMinus" runat="server" TextMode="MultiLine" Rows="7" Width="500"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                &nbsp;
            </td>
            <td>
                <div style="text-align: right; padding-top: 10px;">
                    <button id="btnSave" type="button">
                        Save</button>
                    <button id="btnClose" type="button">
                        Close</button>
                </div>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                &nbsp;
            </td>
            <td>
                <asp:HiddenField ID="hfID" runat="server" />
            </td>
        </tr>
    </table>
    </form>
</body>
</html>
